'''JSON模块演示'''
import json

file_name = "test.txt"


def in_json():
    """
    往JSON中写入数据
    :return:
    """
    with open(file_name, "w+", encoding="UTF-8") as json_obj:
        user_info = dict(user_name="张三", sex="女", age=23, level="土豪")
        json.dump(user_info, json_obj)


def read_json():
    """
    从JSON中读取数据
    :return:
    """
    with open(file_name, "r", encoding="UTF-8") as json_obj:
        user_info = json.load(json_obj)
        print(user_info)


in_json()
read_json()
